﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>欢迎登录后台管理系统</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="js/jquery.js"></script>
    <script src="js/cloud.js" type="text/javascript"></script>
    <script language="javascript">
        $(function(){
            $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
            $(window).resize(function(){
                $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
            })
        });
    </script>
</head>
<body style="background-color:#1c77ac; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">
<div id="mainBody">
    <div id="cloud1" class="cloud"></div>
    <div id="cloud2" class="cloud"></div>
</div>
<div class="logintop">
    <span>欢迎登录后台管理界面平台</span>
    <ul>
        <li><a href="#">回首页</a></li>
        <li><a href="#">帮助</a></li>
        <li><a href="#">关于</a></li>
    </ul>
</div>
<div class="loginbody">
    <span class="systemlogo"></span>
    <div class="loginbox">
        <form id="loginForm" method="post">
            <ul>
                <li><input type="text" name="account" class="loginuser" placeholder="用户名" required/></li>
                <li><input type="password" name="password" class="loginpwd" placeholder="密码" required/></li>
                <li>
                    <input type="submit" class="loginbtn" value="登录"/>
                </li>
                <li id="error" style="color: red;"></li>
            </ul>
        </form>
    </div>
</div>
<div class="loginbm">版权所有  2013  <a href="http://www.uimaker.com">uimaker.com</a>  仅供学习交流，勿用于任何商业用途</div>
</body>
<script>
    $(document).ready(function() {
        $('#loginForm').submit(function(event) {
            event.preventDefault(); // 阻止表单默认提交行为

            var account = $('input[name="account"]').val();
            var password = $('input[name="password"]').val();

            $.ajax({
                url: '/mchant_func/mchant_login',
                type: 'POST',
                data: { account: account, password: password },
                success: function(response) {
                    alert('登录成功');
                    // 将 linkman 存储在 localStorage 中
                    localStorage.setItem('linkman', response.linkman);
                    localStorage.setItem('mid',response.id);
                    localStorage.setItem('mname',response.mname);
                    // 重定向到主页
                    window.location.href = '/main';
                },
                error: function(xhr, status, error) {
                    // 显示错误信息
                    $('#error').text(xhr.responseText);
                    alert('登录失败: ' + xhr.responseText);
                }
            });
        });
    });
</script>
</html>
